package com.leyou.common.utils;
import java.util.ArrayList;
import java.util.List;

public class Test {
    private List<String> list = new ArrayList<>();

    public List<String> getList() {
        return list;
    }

    public void setList(List<String> list) {
        this.list = list;
    }


    public static void main(String[] args) {
        Test testA = new Test();
        List<String> listB = new ArrayList<>();
        for (int i = 0; i < 10000; i++) {
            testA.getList().add("这是个测试"+i);
        }


        Long start = System.currentTimeMillis();
        for (String sstring : testA.getList()) {
            listB.add(sstring);
        }
        Long end = System.currentTimeMillis();
        System.out.println("正常编程所用时间" + (end - start));


        //======================================================================

        List<String> listC = new ArrayList<>();


        Long startC = System.currentTimeMillis();
        testA.getList().forEach(listC::add);
        Long endD = System.currentTimeMillis();

        System.out.println("流式编程所用时间" + (endD - startC));

    }


}